package com.ctcemti.mdm.project.sys.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.handler.inter.IExcelDataModel;
import cn.afterturn.easypoi.handler.inter.IExcelModel;
import com.ctcemti.mdm.project.sys.entity.formdata.BaseReq;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.Id;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.util.Date;

@ApiModel("物资分类表")
@Data
public class SysMaterialClassification extends BaseReq implements IExcelModel,IExcelDataModel,Comparable<SysMaterialClassification> {
    @Id
    @ApiModelProperty(value = "主键id")
    private Integer id;

    @ApiModelProperty(value = "分类名称")
    @Excel(name = "分类名称")
    @NotNull(message = "分类名称不能为空" )
    private String name;

    @ApiModelProperty(value = "物资分类码")
    @Excel(name = "物资分类码")
    @NotNull(message = "物资分类码不能为空" )
    private String code;

    @ApiModelProperty(value = "所属父级编码")
    @Excel(name = "所属父级编码")
    @NotNull(message = "所属父级编码不能为空" )
    private String parentId;

    @ApiModelProperty(value = "排序")
    @Excel(name = "排序")
    @NotNull(message = "排序不能为空")
    @Pattern(regexp = "^-?[0-9]*$",message = "排序只能为整数")
    private String sort;

    @ApiModelProperty(value = "备注")
    @Excel(name = "备注")
    private String comment;

    @ApiModelProperty(value = "创建人")
    private String creator;

    @ApiModelProperty(value = "创建时间")
    private Date createDate;

    @ApiModelProperty(value = "修改人")
    private String modifiedBy;

    @ApiModelProperty(value = "修改时间")
    private Date modifyDate;

    @Transient
    private boolean open = false;

    @Transient
    private boolean parent = true;

    @Transient
    @Excel(name = "错误提示")
    @ApiModelProperty(hidden = true)//swagger忽略属性
    private String errorMsg;

    @Transient
    @ApiModelProperty(hidden = true)//swagger忽略属性
    private int rowNum;

    @Override
    public int compareTo(SysMaterialClassification sysMaterialClassification) {           //重写Comparable接口的compareTo方法，
        return this.rowNum - sysMaterialClassification.getRowNum();// 根据行号升序排列，降序修改相减顺序即可
    }

}